/**
 * china area api
 */
import $http from '../../http/http'

/**
 * 分页获取中国所有区域列表
 */
export const queryAreasPage = (params) => {
    return $http({
        method: "get",
        url: "chinaAreaOperations/queryAreasPage",
        params
    });
}

/**
 * 获取中国所有省份列表
 */
export const getProvinces = () => {
    return $http({
        method: "get",
        url: "chinaAreaOperations/province",
        params: {
        }
    });
}

/**
 * 获取provinceCode对应省份所辖城市列表
 * 
 * @param {所查询城市的父级省份编码} provinceCode 
 */
export const getCities = provinceCode => {
    return $http({
        method: "get",
        url: "chinaAreaOperations/city",
        params: {
            provinceCode: provinceCode
        }
    });
}

/**
 * 获取cityCode对应城市所辖县列表
 * 
 * @param {所查询县的父级市编码} cityCode 
 */
export const getCounties = cityCode => {
    return $http({
        method: "get",
        url: "chinaAreaOperations/county",
        params: {
            cityCode: cityCode
        }
    });
}

/**
 * 获取countyCode对应县所辖乡镇列表
 * 
 * @param {所查询乡镇的父级县编码} countyCode 
 */
export const getTowns = countyCode => {
    return $http({
        method: "get",
        url: "chinaAreaOperations/town",
        params: {
            countyCode: countyCode
        }
    });
}

/**
 * 获取townCode对应乡镇所辖村列表
 * 
 * @param {所查询村的父级乡镇编码} townCode 
 */
export const getVillages = townCode => {
    return $http({
        method: "get",
        url: "chinaAreaOperations/village",
        params: {
            townCode: townCode
        }
    });
}